package com.lannuokeji.biz.items.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.lannuokeji.biz.items.entity.DeviceApply;
import com.lannuokeji.biz.items.mapper.DeviceApplyMapper;
import com.lannuokeji.biz.items.request.DeviceApplyRequest;
import com.lannuokeji.biz.items.service.DeviceApplyService;

/**
 * <p>
 * 申请设备 服务实现类
 * </p>
 *
 * @author lannuoTeck
 * @since 2018-03-19
 */
@Service
public class DeviceApplyServiceImpl extends ServiceImpl<DeviceApplyMapper, DeviceApply> implements DeviceApplyService {

	@Override
	public Page pageWithDevice(Page page, DeviceApply deviceApply) {
		return page.setRecords(baseMapper.page(page, deviceApply));
	}

	@Override
	public boolean createApplyWithDevice(DeviceApplyRequest deviceApplyRequest) {
		// - 先用笨办法实现
		DeviceApply deviceApply = new DeviceApply();
		deviceApply.setStartTime(deviceApplyRequest.getStartTime());
		deviceApply.setEndTime(deviceApplyRequest.getEndTime());
		deviceApply.setPurpose(deviceApplyRequest.getPurpose());
		// 插入申请
		baseMapper.insert(deviceApply);
		return retBool(baseMapper.insertDeviceOfApply(deviceApplyRequest, deviceApply.getId()));
	}

}
